/*
 * @Date: 2023-02-16 10:50:12
 * @LastEditTime: 2023-02-22 16:21:34
 * @FilePath: /hash-guess-game/src/api/module/balance.ts
 * 介绍:
 */
import { defaHttp, ApiRes, ApiReturn } from "../index";

/**获取钱包地址 */
export async function apiWalletAddress(
  data: WalletAddress.Req
): ApiReturn<WalletAddress.Res> {
  const res = await defaHttp.post<ApiRes<WalletAddress.Res>>(
    "/wallet/address",
    { ...data, chain: 99 },
    {
      mode: ["showError"],
    }
  );
  if (res.code !== 200) return;
  return res.data;
}
/**获取钱包地址 */
export namespace WalletAddress {
  export interface Req {
    /**1大小；2：单双；3：幸运；4：定胆玩 */
    type: 1 | 2 | 3 | 4;
  }
  export type Res = string;
}

/**获取游戏余额 */
export async function apiCoinGameBalance(
  data: CoinGameBalance.Req
): ApiReturn<CoinGameBalance.Res> {
  const res = await defaHttp.post<ApiRes<CoinGameBalance.Res>>(
    "/wallet/get_balance",
    data
  );
  if (res.code !== 200) return;
  return res.data;
}
/**获取游戏余额 */
export namespace CoinGameBalance {
  export interface Req {
    coin_id: Id;
  }
  export interface Res {
    /**
     * 示例：80.0030
     */
    /**游戏余额 */
    availbale: string;
    /**
     * 示例：0
     */
    could: number;
  }
}

/**获取提币限制信息 */
export async function apiDrawCoinInfo(
  data: DrawCoinInfo.Req
): ApiReturn<DrawCoinInfo.Res> {
  const res = await defaHttp.post<ApiRes<DrawCoinInfo.Res>>(
    "/get/coin/info",
    data
  );
  if (res.code !== 200) return;
  res.data.min_withdraw = Number(res.data.min_withdraw);
  return res.data;
}

/**获取提币限制信息 */
export namespace DrawCoinInfo {
  export interface Req {
    id: Id;
  }
  export interface Res extends Coin, DrawInfo {}
  export interface DrawInfo {
    /**
     * 最低提币数量，示例：2.0000
     */
    min_withdraw: number;
    /**
     * 提币手续费 %百分号，示例：1.0000
     */
    withdraw_fee: string;
  }
}

